package com.twu.biblioteca;

/**
 * Created by mvargas on 4/29/14.
 */
public class Book {

    private Long id;
    private String name;
    private String author;
    private Integer quantityAvailable;


    public Book(Long id, String name, String author, Integer quantityAvailable) {
        this.id = id;
        this.name = name;
        this.author = author;
        this.quantityAvailable = quantityAvailable;
    }

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (name != null ? !name.equals(book.name) : book.name != null) return false;

        return true;
    }

    public String getAuthor() {
        return author;
    }

    public Integer getQuantityAvailable() {
        return quantityAvailable;
    }

    public boolean hasAvailability() {
        return this.quantityAvailable > 0;
    }

    public void decreaseQuantityBookAvailable() {
        this.quantityAvailable -= 1;
    }
}
